package com.yuexun.beilunpatient.ui.inspect.presenter.impl;

import com.yuexun.beilunpatient.base.BaseEntity;
import com.yuexun.beilunpatient.ui.inspect.bean.JtRmyyCheckResult;
import com.yuexun.beilunpatient.ui.inspect.model.IInspectModel;
import com.yuexun.beilunpatient.ui.inspect.presenter.IInspectPresenter;
import com.yuexun.beilunpatient.ui.inspect.ui.view.IInspectView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/1/29.
 */
public class InspectPresenter implements IInspectPresenter {

    private IInspectView view;
    private IInspectModel model;

    public InspectPresenter(IInspectView view, IInspectModel model) {
        this.view = view;
        this.model = model;
    }

    @Override
    public void inquireBlrmyyCheckPageList(Map<String, String> praise) {
        model.inquireBlrmyyCheckPageList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<JtRmyyCheckResult>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(BaseEntity<JtRmyyCheckResult> bean) {
                        view.showInspectList(bean.getDatas());
                    }
                });
    }
}
